<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0053)http://blog.csdn.net/marising/article/details/4036715 -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Django上传图片用PIL生成缩略图 - 李海波 -- 做影响一亿人的产品 - 博客频道 - CSDN.NET</title>

<meta name="description" content="网上搜过几个版本，一是乱写，二是复杂。容易出错有两个地方:一是不知道怎么从request中读取图片文件，request.FILES[file](file是你上传输入框的名称)就是一个文件，有兴趣可以查看/usr/lib/python2.5/site-packages/django/core/files/uploadedfile.py，就可以知道了。直接操可以了。有些人存本地，再打开，或者又">
<script type="text/javascript" async="" src="./Django上传图片用PIL生成缩略图_files/getnl"></script><script type="text/javascript" async="" src="./Django上传图片用PIL生成缩略图_files/ga.js"></script><script src="./Django上传图片用PIL生成缩略图_files/jquery.js" type="text/javascript"></script>
<script src="./Django上传图片用PIL生成缩略图_files/plugins.js" type="text/javascript"></script>
<script src="./Django上传图片用PIL生成缩略图_files/common.js" type="text/javascript"></script>
<link rel="Stylesheet" type="text/css" href="./Django上传图片用PIL生成缩略图_files/style.css">
<link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="http://blog.csdn.net/marising/rss/list">
<link rel="shortcut icon" href="http://blog.csdn.net/favicon.ico">
<link type="text/css" rel="stylesheet" href="./Django上传图片用PIL生成缩略图_files/default.css">
</head>
<body>
<script src="./Django上传图片用PIL生成缩略图_files/pub_topnav_2011.js" type="text/javascript"></script><link rel="stylesheet" type="text/css" href="./Django上传图片用PIL生成缩略图_files/navtop_2011.css">
<div class="nav_top_2011">
<p>欢迎<em>lvshuchenyin</em><a href="http://my.csdn.net/my/notifications" class="notice_num" id="header_notice_num">0</a>我的：<a href="http://my.csdn.net/my/letter">收件箱<span id="header_letter_num"></span></a><a href="http://download.csdn.net/my" class="red">资源</a><a href="http://write.blog.csdn.net/" class="red">博客</a><a href="http://my.csdn.net/">空间</a><a href="http://passport.csdn.net/account/profile">设置</a>|<a href="http://passport.csdn.net/help/faq">帮助</a>|<a href="http://passport.csdn.net/account/logout">退出</a></p><ul>
<li><a href="http://www.csdn.net/" target="_blank">CSDN首页</a></li>
<li><a href="http://news.csdn.net/" target="_blank">资讯</a></li>
<li><a href="http://bbs.csdn.net/" target="_blank">论坛</a></li>
<li><a href="http://blog.csdn.net/" target="_blank">博客</a></li>
<li><a href="http://download.csdn.net/" target="_blank">下载</a></li>
<li><a href="http://so.csdn.net/" target="_blank">搜索</a></li>
<li class="more"><h2 id="topnav_btnmore"><a href="javascript:void(0);">更多</a></h2>
<ul id="topnav_hidlist">
<li><a href="http://cto.csdn.net/" target="_blank">CTO俱乐部</a></li>
<li><a href="http://student.csdn.net/" target="_blank">学生大本营</a></li>
<li><a href="http://edu.csdn.net/" target="_blank">培训充电</a></li>
<li><a href="http://mobile.csdn.net/" target="_blank">移动开发</a></li>
<li><a href="http://sd.csdn.net/" target="_blank">软件研发</a></li>
<li><a href="http://cloud.csdn.net/" target="_blank">云计算</a></li>
<li><a href="http://www.programmer.com.cn/" target="_blank">程序员</a></li>
<li><a href="http://www.iteye.com/" target="_blank">ITeye</a>&lt;&gt;
</li><li><a href="http://tup.csdn.net/" target="_blank">TUP</a></li>
</ul>
</li>
</ul>
</div>


<div id="container">
<div id="header">
    <div class="header">
        <div id="blog_title">
            <h1>
                <a href="http://blog.csdn.net/marising">李海波 -- 做影响一亿人的产品</a></h1>
            <h2>路漫漫其修远兮，吾将上下而求索</h2>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
</div>
<div id="navigator">
    <div class="navigator_bg">
    </div>
    <div class="navigator">
        <ul>
            <!--<li id="btnHome"><a href="/marising"><span><img src="http://static.blog.csdn.net/images/ico_home.gif">我的首页</span></a></li>-->
            <li id="btnContents"><a href="http://blog.csdn.net/marising?viewmode=contents"><span><img src="./Django上传图片用PIL生成缩略图_files/ico_list.gif">目录视图</span></a></li>
            <li id="btnView"><a href="http://blog.csdn.net/marising?viewmode=list"><span><img src="./Django上传图片用PIL生成缩略图_files/ico_summary.gif">摘要视图</span></a></li>
            <li id="btnRss"><a href="http://blog.csdn.net/marising/rss/list"><span><img src="./Django上传图片用PIL生成缩略图_files/ico_rss.gif">订阅</span></a></li>
</ul>
    </div>
</div>
<script type="text/javascript">
    var username = "marising";
    var blog_address = "http://blog.csdn.net/marising";
    var static_host = "http://static.blog.csdn.net";
    var currentUserName = $.cookie("UserName");
</script>
        
<div id="body">
<div id="main">
<div class="main">
<div class="notice"> 

<a href="http://blog.csdn.net/blogdevteam/article/details/7419530" target="_blank"><font color="red">“第四届中国云计算大会”最新重磅嘉宾抢先报！</font></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://blog.csdn.net/blogdevteam/article/details/7415936" target="_blank"><font color="red">博客频道4月技术图书有奖试读火爆开启</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://ad-apac.doubleclick.net/clk;253093956;76972838;f?http://www.ibm.com/systems/cn/ads/2012q1_bcfc.shtml?crs=apch_cit1_20120206_1328527126975&cm=b&cr=csdn&ct=CN2DG13W&ck=csdn&cmp=CN2DG" target="_blank"><font color="blue">免费下载《SKC易云解决方案》</font></a>
<br>


<a href="http://event.blog.csdn.net/TopColumn/awardlist.aspx" target="_blank"><font color="red">CSDN十大风云博客专栏评选结果公布！</font></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://topic.csdn.net/u/20120416/10/9123faba-8474-4f2a-a0cf-a1b7d0fe5913.html" target="_blank"><font color="red">下载频道分享季1：分享经典，领取积分！</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://event.blog.csdn.net/BlogSkin/Vote.aspx" target="_blank"><font color="red">CSDN博客皮肤评选活动火爆开启！</font></a>
</div><script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/ad.js"></script>

<div id="article_details" class="details">
    <div class="article_title">
    <span class="ico ico_type_Original"></span>
    <h3>
        <span class="link_title"><a href="./Django上传图片用PIL生成缩略图_files/Django上传图片用PIL生成缩略图.htm">
        Django上传图片用PIL生成缩略图
        </a></span>
    </h3>
</div>

        
    <div class="article_manage">
    <span class="link_postdate">2009-03-30 18:12</span>
    <span class="link_view" title="阅读次数">2972人阅读</span>
    <span class="link_comments" title="评论次数"><a href="http://blog.csdn.net/marising/article/details/4036715#comments">评论</a>(4)</span>
    <span class="link_collect"><a href="javascript:void(0);" onclick="javascript:collectArticle(&#39;Django上传图片用PIL生成缩略图&#39;,&#39;4036715&#39;);return false;" title="收藏">收藏</a></span>
    <span class="link_report"><a href="http://blog.csdn.net/marising/article/details/4036715#report" onclick="javascript:report(4036715,2);return false;" title="举报">举报</a></span>
    
</div>

    
<div id="article_content" class="article_content">
    <p>网上搜过几个版本，一是乱写，二是复杂。容易出错有两个地方:</p>
<p>一是不知道怎么从request中读取图片文件，request.FILES['file'](file是你上传输入框的名称)就是一个文件，有兴趣可以查看/usr/lib/python2.5/site-packages/django/core/files/uploadedfile.py，就可以知道了。直接操可以了。有些人存本地，再打开，或者又导入StringIO中，属于多此一举。</p>
<p>二是不知道怎么形成缩略图。其实超级简单，PIL的文档Image模块第二个例子就是讲生成缩略图的。image.thumbnail就可以了。参考：</p>
<p><a href="http://www.pythonware.com/library/pil/handbook/image.htm">http://www.pythonware.com/library/pil/handbook/image.htm</a></p>
<p>&nbsp;</p>
<p>upload.html</p>
<p><div class="dp-highlighter bg_xhtml"><div class="bar"><div class="tools"><b>[xhtml]</b> <a href="http://blog.csdn.net/marising/article/details/4036715#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/marising/article/details/4036715#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/marising/article/details/4036715#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/marising/article/details/4036715#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><div style="position: absolute; left: 722px; top: 727px; width: 18px; height: 18px; z-index: 99; "><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1" class="dp-xml"><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">div</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">"uploader"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">form</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">"upload"</span><span>&nbsp;</span><span class="attribute">enctype</span><span>=</span><span class="attribute-value">"multipart/form-data"</span><span>&nbsp;</span><span class="attribute">action</span><span>=</span><span class="attribute-value">"/ajax/upload/"</span><span>&nbsp;</span><span class="attribute">method</span><span>=</span><span class="attribute-value">"post"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">input</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">"file"</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">"file"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"file"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">input</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"submit"</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"Upload"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;/</span><span class="tag-name">form</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;/</span><span class="tag-name">div</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li></ol></div><textarea cols="50" rows="15" name="code" class="xhtml" style="display: none; ">&lt;div id="uploader"&gt;
	&lt;form id="upload" enctype="multipart/form-data" action="/ajax/upload/" method="post"&gt;
		&lt;input id="file" name="file" type="file"&gt;
		&lt;input type="submit" value="Upload"&gt;
	&lt;/form&gt;
&lt;/div&gt;</textarea> </p>
<p>&nbsp;</p>
<p>view.py</p>
<p><div class="dp-highlighter bg_python"><div class="bar"><div class="tools"><b>[python]</b> <a href="http://blog.csdn.net/marising/article/details/4036715#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command(&#39;ViewSource&#39;,this);return false;">view plain</a><a href="http://blog.csdn.net/marising/article/details/4036715#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command(&#39;CopyToClipboard&#39;,this);return false;">copy</a><a href="http://blog.csdn.net/marising/article/details/4036715#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command(&#39;PrintSource&#39;,this);return false;">print</a><a href="http://blog.csdn.net/marising/article/details/4036715#" class="About" title="?" onclick="dp.sh.Toolbar.Command(&#39;About&#39;,this);return false;">?</a><div style="position: absolute; left: 728px; top: 970px; width: 18px; height: 18px; z-index: 99; "><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1" class="dp-py"><li class="alt"><span><span class="comment">#&nbsp;-*-&nbsp;coding:&nbsp;utf-8&nbsp;-*-</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">from</span><span>&nbsp;django.http&nbsp;</span><span class="keyword">import</span><span>&nbsp;HttpResponse&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">import</span><span>&nbsp;Image&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">def</span><span>&nbsp;upload(request):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;reqfile&nbsp;=&nbsp;request.FILES[<span class="string">'file'</span><span>]&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;image&nbsp;=&nbsp;Image.open(reqfile)&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;image.thumbnail((<span class="number">128</span><span>,</span><span class="number">128</span><span>),Image.ANTIALIAS)&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;image.save(<span class="string">"/home/lhb/1.jpeg"</span><span>,</span><span class="string">"jpeg"</span><span>)&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;HttpResponse(</span><span class="string">"success."</span><span>)&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li></ol></div><textarea cols="50" rows="15" name="code" class="python" style="display: none; "># -*- coding: utf-8 -*-
from django.http import HttpResponse
import Image
def upload(request):    
    reqfile = request.FILES['file']
    image = Image.open(reqfile)
    image.thumbnail((128,128),Image.ANTIALIAS)
    image.save("/home/lhb/1.jpeg","jpeg")
    return HttpResponse("success.")
      </textarea></p>
</div>
<div class="share_buttons" id="sharePanel"><span>分享到：</span> <a name="sina" class="share_sina" title="分享到新浪微博"></a><a name="qq" class="share_qq" title="分享到腾讯微博"></a></div>

<div class="article_next_prev">
        <li class="prev_article">
            <span>上一篇：</span><a href="http://blog.csdn.net/marising/article/details/4030396">fcgi file upload(抛砖引玉)</a></li>
        <li class="next_article">
            <span>下一篇：</span><a href="http://blog.csdn.net/marising/article/details/4047065">Django的多数据库的处理（垂直分库和水平分库）</a></li>
</div>


</div>
<div id="ad_cen"><iframe id="ad_frm_0" frameborder="0" scrolling="no" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; overflow-x: hidden; overflow-y: hidden; width: 732px; height: 95px; " src="./Django上传图片用PIL生成缩略图_files/ad(2).htm"></iframe></div>
<script type="text/javascript">
    new Ad(4, 'ad_cen');
</script>
<div id="comment_title" class="panel_head">查看评论<a name="comments"></a></div>
<div id="comment_list"><dl class="comment_item comment_topic" id="comment_item_1378657"><dt class="comment_head" floor="4">4楼 <span class="user"><a class="username" href="http://blog.csdn.net/marising" target="_blank">marising</a> <span class="ptime">2010-05-12 20:05发表</span>  <a href="http://blog.csdn.net/marising/article/details/4036715#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="1378657" username="marising"> <a href="http://blog.csdn.net/marising/article/details/4036715#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/marising/article/details/4036715#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/marising" target="_blank"><img src="./Django上传图片用PIL生成缩略图_files/3_marising.jpg" width="40" height="40"></a></dd><dd class="comment_body">你看看是否有这个目录'/mytest/photo/upload'</dd></dl><dl class="comment_item comment_topic" id="comment_item_1349094"><dt class="comment_head" floor="3">3楼 <span class="user"><a class="username" href="http://blog.csdn.net/%E5%8C%BF%E5%90%8D%E7%94%A8%E6%88%B7" target="_blank">匿名用户</a> <span class="ptime">2010-04-19 10:27发表</span>  <a href="http://blog.csdn.net/marising/article/details/4036715#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="1349094" username="匿名用户"> <a href="http://blog.csdn.net/marising/article/details/4036715#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/marising/article/details/4036715#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/%E5%8C%BF%E5%90%8D%E7%94%A8%E6%88%B7" target="_blank"><img src="./Django上传图片用PIL生成缩略图_files/3_匿名用户.jpg" width="40" height="40"></a></dd><dd class="comment_body">在保存的时候  它提示我<br><br>[Errno 2] No such file or directory: u'/mytest/photo/upload/2.png'<br><br>我已经写一个什么地址来保存呢 ？<br><br>谢谢</dd></dl><dl class="comment_item comment_topic" id="comment_item_1177514"><dt class="comment_head" floor="2">2楼 <span class="user"><a class="username" href="http://blog.csdn.net/marising" target="_blank">marising</a> <span class="ptime">2009-11-16 00:11发表</span>  <a href="http://blog.csdn.net/marising/article/details/4036715#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="1177514" username="marising"> <a href="http://blog.csdn.net/marising/article/details/4036715#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/marising/article/details/4036715#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/marising" target="_blank"><img src="./Django上传图片用PIL生成缩略图_files/3_marising.jpg" width="40" height="40"></a></dd><dd class="comment_body">image.save(&amp;quot;/home/lhb/1.jpeg&amp;quot;,&amp;quot;jpeg&amp;quot;)<br>===========================<br>你可以看看save方法的参数是否支持gif</dd></dl><dl class="comment_item comment_topic" id="comment_item_1159700"><dt class="comment_head" floor="1">1楼 <span class="user"><a class="username" href="http://blog.csdn.net/pely122" target="_blank">pely122</a> <span class="ptime">2009-10-13 10:35发表</span>  <a href="http://blog.csdn.net/marising/article/details/4036715#reply" class="cmt_btn reply" title="回复">[回复]</a> <span class="comment_manage" style="display:none;" commentid="1159700" username="pely122"> <a href="http://blog.csdn.net/marising/article/details/4036715#quote" class="cmt_btn quote" title="引用">[引用]</a> <a href="http://blog.csdn.net/marising/article/details/4036715#report" class="cmt_btn report" title="举报">[举报]</a></span></span></dt><dd class="comment_userface"><a href="http://blog.csdn.net/pely122" target="_blank"><img src="./Django上传图片用PIL生成缩略图_files/3_pely122.jpg" width="40" height="40"></a></dd><dd class="comment_body">要是上传GIF图片怎么弄呢？会报错</dd></dl><div class="clear"></div></div>
<div id="comment_bar" style="display: none; "></div>
<div id="comment_form"><a name="commentbox"></a><a name="reply"></a><a name="quote"></a><form action="http://blog.csdn.net/marising/comment/submit?id=4036715" method="post"><div class="commentform"><div class="panel_head">发表评论</div><ul><li class="left">用 户 名：</li><li class="right">lvshuchenyin</li></ul><ul><li class="left">评论内容：</li><li class="right" style="position:relative;"><div id="ubbtools"><a href="http://blog.csdn.net/marising/article/details/4036715#insertcode" code="code"><img src="./Django上传图片用PIL生成缩略图_files/code.gif" border="0" alt="插入代码" title="插入代码"></a></div><div id="lang_list" style="display:none; position:absolute;top:25px; left:0px;"><a href="http://blog.csdn.net/marising/article/details/4036715#html">HTML/XML</a><a href="http://blog.csdn.net/marising/article/details/4036715#javascript">JavaScript</a><a href="http://blog.csdn.net/marising/article/details/4036715#css">CSS</a><a href="http://blog.csdn.net/marising/article/details/4036715#php">PHP</a><a href="http://blog.csdn.net/marising/article/details/4036715#csharp">C#</a><a href="http://blog.csdn.net/marising/article/details/4036715#cpp">C++</a><a href="http://blog.csdn.net/marising/article/details/4036715#java">Java</a><a href="http://blog.csdn.net/marising/article/details/4036715#python">Python</a><a href="http://blog.csdn.net/marising/article/details/4036715#ruby">Ruby</a><a href="http://blog.csdn.net/marising/article/details/4036715#vb">Visual Basic</a><a href="http://blog.csdn.net/marising/article/details/4036715#delphi">Delphi</a><a href="http://blog.csdn.net/marising/article/details/4036715#sql">SQL</a><a href="http://blog.csdn.net/marising/article/details/4036715#plain">其它</a></div><textarea class="comment_content" name="comment_content" id="comment_content" style="width: 400px; height: 200px;"></textarea></li></ul><ul><input type="hidden" id="comment_replyId" name="comment_replyId"><input type="hidden" id="comment_userId" name="comment_userId" value="521203"><input type="hidden" id="commentId" name="commentId" value=""><input type="submit" class="comment_btn" value="提交">&nbsp;&nbsp;<span id="tip_comment" style="color: Red; display: none;"></span></ul></div></form></div>
<div class="announce">* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div>
<script type="text/javascript">
    var fileName = '4036715';
    var commentscount = 4;
    var islock = false
</script>
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/comment.js"></script>
<div id="ad_bot"><iframe id="ad_frm_1" frameborder="0" scrolling="no" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; overflow-x: hidden; overflow-y: hidden; width: 732px; height: 170px; " src="./Django上传图片用PIL生成缩略图_files/ad(3).htm"></iframe></div>
<script type="text/javascript">
    new Ad(5, 'ad_bot');
</script>
<div id="report_dialog"></div>


<div class="clear"></div>
</div>
</div>
<div id="side">
    <div class="side">
<div id="panel_Profile" class="panel">
    <ul class="panel_head"><span>个人资料</span></ul>
    <ul class="panel_body profile">
        <div id="blog_userface">
            <a href="http://my.csdn.net/marising" target="_blank">
            <img src="./Django上传图片用PIL生成缩略图_files/1_marising.jpg" title="访问我的空间" style="max-width:90%">
            </a>
            <br>
            <span><a href="http://my.csdn.net/marising" target="_blank">marising</a></span>
        </div>
<div class="interact">
<!--<a href="#" class="attented" title="已关注"></a>-->
<a href="http://blog.csdn.net/marising/article/details/4036715#" class="attent" id="span_add_follow" title="[加关注]"></a>
<a href="http://my.csdn.net/my/letter/send/marising" class="letter" title="[发私信]"></a>
</div>
        <div id="blog_medal">
        <div id="bms_box"></div></div>
        <ul id="blog_rank">
            <li>访问：<span>170875次</span></li>
            <li>积分：<span>3052分</span></li>
            <li>排名：<span>第1221名</span></li>
        </ul>
        <ul id="blog_statistics">
            <li>原创：<span>113篇</span></li>
            <li>转载：<span>9篇</span></li>
            <li>译文：<span>1篇</span></li>
            <li>评论：<span>231条</span></li>
        </ul>
    </ul>
</div>

<script type="text/javascript">
var _blogger='marising';
$(document).ready(function () {
    $('#span_add_follow').click(function () {
        var url = "http://my.csdn.net/index.php/follow/do_follow?jsonpcallback=?";
        $.getJSON(url, { "username": _blogger }, function (data) {
            if (data.succ == 1) {
                alert('关注成功！');
                $('#span_add_follow').attr('class', 'attented').click(function () { return false; });
            } else {
                alert(data.msg);
            }
        });
    });
    if (getUN().toLowerCase() == _blogger.toLowerCase()) {
        $('.interact').hide();
    }
});
function getUN() {
    var m = document.cookie.match(new RegExp("(^| )UserName=([^;]*)(;|$)"));
    if (m) return m[2];
    else return '';
}
</script>

<div class="panel" id="panel_Search">
    <ul class="panel_head"><span>文章搜索</span></ul>
    <ul class="panel_body">
        <form id="frmSearch" action="http://so.csdn.net/search" class="form_search" target="_blank">
        <span><input id="inputSearch" type="text" class="blogsearch" title="请输入关键字"></span>
        <input id="btnSubmit" type="submit" value="搜索" title="search in blog">
        <input type="hidden" name="q" id="inputQ">
        <input type="hidden" name="t" value="blog">
        <a id="btnSearchBlog" target="_blank"></a>
        </form>
    </ul>
</div><div id="panel_Category" class="panel">
    <ul class="panel_head"><span>文章分类</span></ul>
    <ul class="panel_body">
        <li>
        <a href="http://blog.csdn.net/marising/article/category/628965">1.自然语言处理/机器学习</a><span>(14)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/marising/article/category/337706">2.Linux/C/Python</a><span>(47)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/marising/article/category/18561">3.软件设计/架构/测试</a><span>(24)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/marising/article/category/306043">4.产品研究/点评/创意</a><span>(10)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/marising/article/category/14375">5.软件工程/管理</a><span>(20)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/marising/article/category/14392">6.杂七杂八</a><span>(8)</span>
        
        </li>
    </ul>
</div><div id="panel_Archive" class="panel">
    <ul class="panel_head"><span>文章存档</span></ul>
    <ul class="panel_body">
        <div id="archive_list"><li><a href="http://blog.csdn.net/marising/article/month/2012/03">2012年03月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/10">2011年10月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/09">2011年09月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/07">2011年07月</a>(3)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/06">2011年06月</a>(2)</li><span class="hidelist" style="display:none;"><li><a href="http://blog.csdn.net/marising/article/month/2011/05">2011年05月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/04">2011年04月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/03">2011年03月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/02">2011年02月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2011/01">2011年01月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/12">2010年12月</a>(5)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/11">2010年11月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/10">2010年10月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/09">2010年09月</a>(8)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/08">2010年08月</a>(4)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/07">2010年07月</a>(4)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/06">2010年06月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/02">2010年02月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2010/01">2010年01月</a>(7)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/12">2009年12月</a>(4)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/11">2009年11月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/09">2009年09月</a>(4)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/08">2009年08月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/07">2009年07月</a>(3)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/06">2009年06月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/05">2009年05月</a>(3)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/04">2009年04月</a>(5)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/03">2009年03月</a>(7)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/02">2009年02月</a>(3)</li><li><a href="http://blog.csdn.net/marising/article/month/2009/01">2009年01月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/12">2008年12月</a>(3)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/11">2008年11月</a>(4)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/10">2008年10月</a>(6)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/09">2008年09月</a>(5)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/08">2008年08月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/07">2008年07月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/03">2008年03月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2008/01">2008年01月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2007/11">2007年11月</a>(3)</li><li><a href="http://blog.csdn.net/marising/article/month/2007/10">2007年10月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2007/09">2007年09月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2007/04">2007年04月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2007/02">2007年02月</a>(3)</li><li><a href="http://blog.csdn.net/marising/article/month/2006/12">2006年12月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2006/11">2006年11月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2006/08">2006年08月</a>(1)</li><li><a href="http://blog.csdn.net/marising/article/month/2006/07">2006年07月</a>(2)</li><li><a href="http://blog.csdn.net/marising/article/month/2004/07">2004年07月</a>(1)</li></span><div id="archive_list_button" class="list_closed">展开</div></div>
    </ul>
</div>
<div id="hotarticls" class="panel">
    <ul class="panel_head"><span>阅读排行</span></ul>
    <ul class="panel_body">
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5256910" title="阿凡达架构平台（Avatar Architecture Platform）（一）">阿凡达架构平台（Avatar Archi...</a> (14214)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5182771" title="压力测试衡量CPU的三个指标：CPU Utilization、Load Average和Context Switch Rate">压力测试衡量CPU的三个指标：CPU U...</a> (9650)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5186643" title="高性能服务器架构(High-Performance Server Architecture)">高性能服务器架构(High-Perfor...</a> (8580)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/2845339" title="Python调用c/c++函数（1）">Python调用c/c++函数（1）</a> (7069)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/2962322" title="C++调用Python(4）">C++调用Python(4）</a> (6218)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/4567531" title="std list/vector sort 排序就这么简单">std list/vector sort...</a> (5879)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/2917892" title="C++调用Python(3)">C++调用Python(3)</a> (5691)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5264360" title="阿凡达架构平台（Avatar Architecture Platform）（二）">阿凡达架构平台（Avatar Archi...</a> (4037)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/3069346" title="C++模板引擎Ctemplate的介绍">C++模板引擎Ctemplate的介绍</a> (4036)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/3932938" title="nginx＋fastcgi+c/c++搭建高性能Web框架">nginx＋fastcgi+c/c++搭...</a> (3905)
        </li>
    </ul>
</div>
<div id="hotarticls" class="panel">
    <ul class="panel_head"><span>评论排行</span></ul>
    <ul class="panel_body">
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5256910" title="阿凡达架构平台（Avatar Architecture Platform）（一）">阿凡达架构平台（Avatar Archi...</a> (55)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5286747" title="阿凡达架构平台（Avatar Architecture Platform）（三）">阿凡达架构平台（Avatar Archi...</a> (17)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5186643" title="高性能服务器架构(High-Performance Server Architecture)">高性能服务器架构(High-Perfor...</a> (13)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5264360" title="阿凡达架构平台（Avatar Architecture Platform）（二）">阿凡达架构平台（Avatar Archi...</a> (12)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5844063" title="基于libsvm的中文文本分类原型">基于libsvm的中文文本分类原型</a> (12)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/6580529" title="看到新的CSDN的博客界面，泪流满面">看到新的CSDN的博客界面，泪流满面</a> (11)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/1506224" title="为什么第一次调用WebService慢呢？">为什么第一次调用WebService慢呢...</a> (6)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/5713314" title="网站性能测试PV到TPS的转换以及TPS的波动">网站性能测试PV到TPS的转换以及TPS...</a> (5)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/4083650" title="中文分词的一些研究记录">中文分词的一些研究记录</a> (5)
        </li>
        <li>
            <a href="http://blog.csdn.net/marising/article/details/2064939" title="memset效率问题">memset效率问题</a> (5)
        </li>
    </ul>
</div>
<div id="homepageArticles" class="panel">
    <ul class="panel_head"><span>推荐文章</span></ul>
    <ul class="panel_body" id="ad_commend"><iframe id="ad_frm_2" frameborder="0" scrolling="no" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; overflow-x: hidden; overflow-y: hidden; width: 182px; height: 296px; " src="./Django上传图片用PIL生成缩略图_files/ad.htm"></iframe></ul>
</div>
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/ad.js"></script>
<script type="text/javascript">
    new Ad(12, 'ad_commend');
</script><div id="newcomments" class="panel">
<ul class="panel_head"><span>最新评论</span></ul>
<ul class="panel_body">
    <li>
    <a href="http://blog.csdn.net/marising/article/details/6543943#comments">信息检索（IR）的评价指标介绍 - 准确率、召回率、F1、mAP、ROC、AUC</a>
    <p style="margin:0px;">yongge1981:
灰常不错
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/5182771#comments">压力测试衡量CPU的三个指标：CPU Utilization、Load Average和Context Switch Rate</a>
    <p style="margin:0px;">jerrywang1974:
很清楚也很棒的文章!
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/3950026#comments">JIRA自定义字段设置</a>
    <p style="margin:0px;">xiaoxm_001:
根本没有解决问题，首先文章写的不错很有条理，不过很好奇的问一下，你的Task Terminate S...
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/3605991#comments">google protocol buffer在python中使用utf-8的问题</a>
    <p style="margin:0px;">Xiao_Qiang_:
readMe.txt中说有好多bug的，还是java和c++的版本号The Python imple...
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/1506224#comments">为什么第一次调用WebService慢呢？</a>
    <p style="margin:0px;">marising:
@ddjunshuhong:asp.net没有这个问题，你仔细想想
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/3950026#comments">JIRA自定义字段设置</a>
    <p style="margin:0px;">liusay:
收藏了，谢谢分享
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/1506224#comments">为什么第一次调用WebService慢呢？</a>
    <p style="margin:0px;">ddjunshuhong:
楼主上面主要讲的是客户端第一次调用webservice慢的解决方法。那如果是webform第一次调用...
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/5661979#comments">VIPS:基于视觉的页面分割算法[微软下一代搜索引擎核心分页算法]（介绍）</a>
    <p style="margin:0px;">marising:
代码实在不方便发。
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/5661979#comments">VIPS:基于视觉的页面分割算法[微软下一代搜索引擎核心分页算法]（介绍）</a>
    <p style="margin:0px;">yiyikobe:
LZ大神有没具体实现的代码或者是方法，成型的。。有木有。如果有的话 麻烦给我发一份 我现在急需。。z...
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/marising/article/details/5160210#comments">LoadRunner压力测试时监控服务器Linux的资源情况</a>
    <p style="margin:0px;">tongle_deng:
磁盘    Collision rate    每秒钟在以太网上检测到的冲突数这个怎么归入了磁盘下呢...
    </p>
    </li>
</ul>
</div>
<div id="custom_column_939464" class="panel">
    <ul class="panel_head"><span>产品</span></ul>
    <ul class="panel_body">
        <ul><li><a href="http://www.inspur.com/products/channel_soft/gs_4370.shtml" target="_blank">浪潮GSP(做过的产品)</a></li><li><a href="http://www.cutt.com/" target="_blank">简网(做过的产品)</a></li></ul>
    </ul>
</div><div id="custom_column_939465" class="panel">
    <ul class="panel_head"><span>牛人</span></ul>
    <ul class="panel_body">
        <ul><li><a href="http://blog.csdn.net/xushiweizh/" target="_blank">许世伟(StdEx作者C++大牛)</a></li><li><a href="http://juqiang.cnblogs.com/" target="_blank">鞠强(.Net Performance的老大)</a></li></ul>
    </ul>
</div>    </div>
    <div class="clear">
    </div>
</div>

<div class="clear"></div>
</div>
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/shCore-src.js"></script>
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/ZeroClipboard.js"></script>
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/article_code.js"></script>

<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/show.js"></script>
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/showblogmedal.ashx"></script>
<script type="text/javascript">document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</script><img src="./Django上传图片用PIL生成缩略图_files/pv.aspx" border="0" width="0" height="0">
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/counter.js"></script><script type="text/javascript" charset="UTF-8" src="./Django上传图片用PIL生成缩略图_files/msg.popup.js"></script><img src="./Django上传图片用PIL生成缩略图_files/visitlog.php" width="1" height="1" border="0" alt="">
<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/publib_footer.js"></script><link rel="stylesheet" type="text/css" href="./Django上传图片用PIL生成缩略图_files/pub_footerstyle.css"><div class="pub_footerall"><dl><dt></dt> <dd><a href="http://www.csdn.net/company/about.html" target="_blank">公司简介</a>|<a href="http://www.csdn.net/company/recruit.html" target="_blank">招贤纳士</a>|<a href="http://www.csdn.net/company/marketing.html" target="_blank">广告服务</a>|<a href="http://www.csdn.net/company/account.html" target="_blank">银行汇款帐号</a>|<a href="http://www.csdn.net/company/contact.html" target="_blank">联系方式</a>|<a href="http://www.csdn.net/company/statement.html" target="_blank">版权声明</a>|<a href="http://www.csdn.net/company/layer.html" target="_blank">法律顾问</a>|<a href="mailto:webmaster@csdn.net">问题报告</a></dd><dd>北京创新乐知信息技术有限公司 版权所有,&nbsp;京&nbsp;ICP&nbsp;证&nbsp;070598&nbsp;号</dd><dd>世纪乐知(北京)网络技术有限公司 提供技术支持</dd><dd>江苏乐知网络技术有限公司 提供商务支持</dd><dd><img src="./Django上传图片用PIL生成缩略图_files/pic_email.gif" alt="" title=""> Email:webmaster@csdn.net</dd><dd>Copyright © 1999-2011, CSDN.NET, All Rights Reserved</dd><dd><a href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010" target="_blank"><img src="./Django上传图片用PIL生成缩略图_files/gongshang_logos.gif" alt="GongshangLogo" title=""></a></dd></dl></div>


<script type="text/javascript" src="./Django上传图片用PIL生成缩略图_files/ad(1).js"></script>


</div>

<img style="width: 1px; height: 1px; position: absolute; visibility: hidden; " src="./Django上传图片用PIL生成缩略图_files/show.aspx"><img style="width: 1px; height: 1px; position: absolute; visibility: hidden; " src="./Django上传图片用PIL生成缩略图_files/view.aspx"></body></html>